// pages/admin/income/withdrawDetails/withdrawDetails.js
const app = getApp();
var util = require('../../../../utils/util.js');
import Api from '../../../../utils/http'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList: [{}, {}, {}, {}],
    endMonth: util.formatMonth(new Date), //限制不可选取未来的月份
    currMonth: '查看本月',
    currDepartIndex: '',
    currDepart: '所有部门',
    currKindsIndex: '',
    // currKinds: '所有分类',
    codes:null,
    departArr: ['部门1', '部门1', '部门1', '部门1', '部门1'],
    kindsArr: ['分类1', '分类1', '分类1', '分类1', '分类1'],

    claimList: [{}, {}, {}, {}, {}, {}, {}]
  },
  //选择月份
  bindMonthPicker: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      currMonth: e.detail.value
    })
    this.getWaterMonth(e);
  },
  //选择部门
  bindDepartPicker: function(e) {
    var that = this;
    console.log('picker发送选择改变，携带值为', e.detail.value)
    var _index = e.detail.value;
    this.setData({
      currDepartIndex: e.detail.value,
      currDepart: that.data.departArr[_index]
    })
  },
  //选择分类
  bindKindsPicker: function(e) {
    var that = this;
    console.log('picker发送选择改变，携带值为', e.detail.value)
    var _index = e.detail.value;
    this.setData({
      currKindsIndex: e.detail.value,
      currKinds: that.data.kindsArr[_index]
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that=this;
    that.getWater();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
  //提现明细
  getWaterMonth: function(e) {
    var that = this;
    console.log(that.data,e)
    var uid=wx.getStorageSync('userid');
    var param = {
      uid: uid.id,
      // did: 0, // 部门id
      time: e.detail.value.toString() ,// 时间 y-m-d
    }
    console.log(param)
    Api.ajax('/app/Zmanage/water', param).then(res => {
      console.log(res)
      if (res.code == 200) {
        that.setData({
          claimList: res.data,
          codes:res.code
        })
      }
    })
  },
  //提现明细
  getWater: function(e) {
    var that = this;
    console.log(that.data,e)
    var uid=wx.getStorageSync('userid');
    var param = {
      uid: uid.id,
      did: 0, // 部门id
      time: e.detail.value.toString() ,// 时间 y-m-d
    }
    console.log(param)
    Api.ajax('/app/Zmanage/water', param).then(res => {
      console.log(res)
      if (res.code == 200) {
        that.setData({
          claimList: res.data,
          codes:res.code
        })
      }
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})